#
# libgist dataset processing
#

"""This module provides various functions to help with loading libgist
datasets."""

#---------------------------- ADMINISTRIVIA -----------------------------

# This file is part of libgist.
#
# libgist is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# libgist is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with libgist; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA.

# REVISION HISTORY
#
# $HeadURL: http://libgist.googlecode.com/svn/branches/lazebnik_dev/conf/conf/dataset.py $
# $Id: dataset.py 68 2011-09-26 22:44:25Z libgist@gmail.com $

#------------------------------ IMPORTS --------------------------------

# libgist
import local_settings

# Python standard library
import os, sys

#--------------------------- TRAINING IMAGES ----------------------------

# Return lists of training images for different categories
def build_training_list(dataset_name):
   """This function returns a dictionary whose keys specify the different
image categories and whose values are the lists of training images for
each category."""

   root = local_settings.dataset_root(dataset_name)
   training_images = {}
   for cat in local_settings.categories(dataset_name):
      p = root + os.path.sep + cat + os.path.sep
      if os.path.isdir(p):
         training_images[cat] = [p+i for i in (sorted(os.listdir(p)))[0:50]]
      else:
         sys.stderr.write(p + ': no such directory\n')
   return training_images

#------------------------------------------------------------------------

# So things look consistent in everyone's emacs...
# Local Variables:
# indent-tabs-mode: nil
# End:
